Skip to content

Conversation

@momstrosity
Copy link

Implement RGB to Hex Color Converter

Description

Task

Implement RGB to Hex Converter

Acceptance Criteria

  • Accept three integers (0-255) for R, G, and B
  • Return hex string in format '#RRGGBB'
  • Handle invalid input values
  • Pad single digit values with zeros

Summary of Work

Overview

This pull request implements a robust RGB to Hex color converter function with comprehensive error handling and testing.

Changes Made

  • Created src/rgb_to_hex.py with rgb_to_hex() function
  • Implemented thorough input validation
  • Added comprehensive test suite in tests/test_rgb_to_hex.py

Implementation Details

Function Capabilities

  • Converts RGB color values (0-255) to hexadecimal color codes
  • Handles input validation for:
    • Integer type checking
    • Value range (0-255 for each color channel)
  • Returns hex color code with leading '#' and zero-padded values

Error Handling

  • Raises TypeError for non-integer inputs
  • Raises ValueError for out-of-range color values
  • Ensures consistent hex color code formatting

Testing Approach

Implemented 5 test cases covering:

  1. Basic color conversions
  2. Zero value conversions
  3. Hex value padding
  4. Invalid input ranges
  5. Type error handling

Test Results

  • All 5 tests passed successfully
  • 100% coverage of primary functionality and edge cases

Acceptance Criteria

✓ Correctly converts RGB to Hex
✓ Handles input validation
✓ Provides clear error messages
✓ Comprehensive test coverage

Notes

  • Function uses f-string formatting for efficient hex conversion
  • Follows Python type hinting best practices

Changes Made

  • Created src/rgb_to_hex.py with RGB to Hex conversion function
  • Added comprehensive input validation
  • Implemented zero-padding for hex values
  • Created tests/test_rgb_to_hex.py with multiple test scenarios

Tests

  • Basic color conversion tests
  • Zero value conversion tests
  • Hex value padding tests
  • Invalid input range tests
  • Type error handling tests

Signatures

Staking Key

AEghvdqmRtc3fjKXfNTMJJ6WshksgWuJ9YBExgsZu8cN: JJFqysiKLyQAf9Jjkj2A2eAKuFuWXPPR5mdQwfdH5GaXzbCJtkkyzNveCPYfNqZyuXoqiW85G4r66Ka324mbsPj77CYE6pHxHUhdCd123S4RD6end82tTN9gwvsucLMvGgoxCtx4MxCcjbdw38kAVB5pgpLXmycxqPYkiBZUkep7tJWZNKJsTgzMkNzGdFP7fdtmz9ctvdHByFQ6LTboxvVFJq92GnrkD9WybsGVtkg1WqWZtyiwYrbKdePL7cmQp1Ds6i7f9nuYeLxUVQ27SaXJuHY1FCn7Uodp8s6VmpxHEV2b8JB11kW63WznkiNbhxgTfq77VM3PocgapX27q5Ev2rsMbn9vDD69tLgzFyxevvdY3qE6smwCj3KtiMH6XVu383o8xz9nv1Vcs1ZC4BrmMqwUwNWAJ8

Public Key

AwXAtX7tMhL4JyB8NfXdsrqc1UifaMyap3c9bpN9RMse: AM6E1LD1F3nadHoSkqFKFfqx3HKrBsDCwHQwAU3nF5UmyS8PvCc69aCt37BQLcpycKbVFSJCiZWN8MNDH2NhNoCrvjxMkL6CBq9aZVcv7w9ohBCXqPztFgZNb96Tnhx4tis4MmhpKdxZ5GHWPvnBm6nm7z8nmaM2htexivmYaGCimKVfpEM93CcXG2SAnQ8uogjqNrgPrw4XTHH6nz8P7TEnU7tbzdx41cyiQPcjMp6y7d2sde9iebEzFVEadx6RksXxVoBLYDyKbLJ82hm3ppTD5SQRGkHPVSRsDABBubVtzGVBkbEee8YhfEac4YHNCv6okKoc8bT8VvtR9FUaH9k6hD79Gx2W5brJHBYQWqq7bop7yPJCLSEgTLK8ADwkaWmaFkXuGrjs7R4zUZ7MFD3Z4Kw2N6MYrx

@labrocadabro
Copy link

RGB to Hex Color Conversion

Description

Implements a function to convert RGB color values to hexadecimal color codes

Recommendation

APPROVE

Reasons:

  • Implements RGB to Hex conversion correctly
  • Comprehensive test coverage
  • Proper error handling
  • Meets all specified requirements

Unmet Requirements

All requirements met

Tests

Failed Tests

No failing tests

Missing Test Cases

No missing test cases identified

Action Items

No action items required

Signatures

Staking Key

7aAADu3aXXncSyvSVErKbQqGF3caWZkVz9MSLorvgv2f: 276Lyqwt3h4eSybLL3C1E4hDmWz7ksZTmPXTEFVAqQNUW98Zn3Qp5B2UEaNULbkeJHVXg9subBGa8G5DY5ySUDTWyTzrG78JzZHtXEDEapV8KsiFQyyehgB6kzLQdit5tKUGRFyrVwavrGGYjxjf6QzB2KGMN9c1nPwW2WQ3csmyACHrX7c1yWAnf75b6ix7rs2RLu147Nk9kh8HtL1BkwuVbkom3KjNY8if1EEc9La53HfAc3F1zULtyB9dB3wNDd7Qxsxy97UuTr

Public Key

2R7RRyEP2A4agg5rfY1HxPKhugqgDSnDmsbdZpkEcbeF: Z7LY3c7TB2RASBExzffodp7ajEf7jPgrQ8LygTUtMivwWnNRXu1CnUs4X6poPzWGHDSLFef5Q1ixVvGwDoZksQ9myyf3djZ1d7hi45sVtQyod6n76fMeSa6DKHjGnREx1ntnh9Lywa6XXCK45UbPEdB3uatTiV12SwEkKp3ys4Ss3eTv8r9Ljxt4ySDGXsgkmtyCRbmjHbpVkHPY6usnSQWXrfqWEchmTMfH6trLcoNicYPE55tm75WxuSnnhfswTYCmaiLDHk3yE

@laura-abro
Copy link
Owner

RGB to Hex Color Conversion Implementation

Description

Implementation of a function to convert RGB color values to hexadecimal color code

Recommendation

APPROVE

Reasons:

  • Correct implementation of RGB to hex conversion
  • Comprehensive test coverage
  • Proper error handling for invalid inputs
  • Follows specified file structure requirements

Unmet Requirements

All requirements met

Tests

Failed Tests

No failing tests

Missing Test Cases

No missing test cases identified

Action Items

No action items required

Signatures

Staking Key

5EmgCQSgPD79JWPQ6KMAV35kUNxasNQymeWuQXfJPmVk: jvuRoGvDJN67Hzx6Hac2cHMWrxa2mDDox9Yh6Nh7etVa8uqoT5DU3oLdxENkXK8bDQXn9jE1MrkDhaRqZMhLfsjJACzSp7F5LgN552VKjacDpJ5KyG1Xv1yQfWa391wu8LQ3eFRxGUXyRcBK2J2SUkmb4uDpQbH7FTx6Yd2h2YmxnsjXcGNwH8cm1DiihRwqoULX5KSFyBibbm6s7bjmwRYmBNZkpaZPZNzsMMyXtLKf2oVHEZcHLthTN5fgCpep5FNxjojSnnzVi

Public Key

8U4eXGpP28X2i8wDEDxwGUdSdPuz7xuMBvpFuVyPDNKz: 25tXsba4rSXjp5hH1F5aZFdjX2JKpin5GZQcYjASk6XEe9tMdGWEerUJk4gzVnMv8d9uVADrF6JrJDnfZqkQCcL45EfDEpNHuWjgSaHarJpckABV4xgDyJ2VVYVtbGcaTuGTRJGk5i949RgHHea33MCbDgL81ZuBRVi1XxJPpQP3JdXUqZbLPWifdfD25e9uzpPtHXfr4STxbJPiEjzEPVxLoDg6BXoDodADUMjSrM5F5ZWAjtxJ3JzeYChAAdCgpGiF1BZ5NX9Am2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants